const express = require('express');
const router = express.Router();

// 导入工具
const { success } = require('../utils/response');

/**
 * 健康检查
 * GET /health
 */
router.get('/', (req, res) => {
  const healthInfo = {
    status: 'OK',
    timestamp: new Date().toISOString(),
    uptime: process.uptime(),
    environment: process.env.NODE_ENV || 'development',
    version: process.env.npm_package_version || '1.0.0'
  };
  
  success(res, healthInfo, '服务运行正常');
});

/**
 * 详细健康检查
 * GET /health/detailed
 */
router.get('/detailed', (req, res) => {
  const detailedHealth = {
    status: 'OK',
    timestamp: new Date().toISOString(),
    uptime: process.uptime(),
    environment: process.env.NODE_ENV || 'development',
    version: process.env.npm_package_version || '1.0.0',
    memory: process.memoryUsage(),
    cpu: process.cpuUsage(),
    platform: process.platform,
    nodeVersion: process.version
  };
  
  success(res, detailedHealth, '详细健康信息');
});

module.exports = router;
